import { defineStore } from "pinia";
import { getDepartmentAPI, getHospitalDetailAPI } from "@/api/hospital";
import type { HospitalDepartmentData, HospitalDetailResponseData } from "@/api/hospital/type";
import type { DetailState } from "./interface";
import type { HospitalDetailInfo } from "@/api/hospital/type";

const useDetailStore = defineStore('Detail', {
    state: (): DetailState => {
        return {
            detailData: ({} as HospitalDetailInfo),
            departmentData: []
        }
    },
    actions: {
        async getHospitalDetail(hoscode: string) {
            const res: HospitalDetailResponseData = await getHospitalDetailAPI(hoscode)
            this.detailData = res.data
        },
        async getDepartment(hoscode: string) {
            const res: HospitalDepartmentData = await getDepartmentAPI(hoscode)
            this.departmentData = res.data
        }
    },
    getters: {

    }
})

export default useDetailStore